// typeforces + nice statement, what can i say man
#include<bits/stdc++.h>
using namespace std;

const int N=1e6+5,inf=0x3f3f3f3f;
namespace sgt {
	int ls[2*N],rs[2*N],cnt;
	struct data {
		int lb=0,rb=0,res=0,a0=inf,mlb=-inf,mrb=inf;
	} val[2*N];
	data merge (data x,data y) {
		data res;
		if (x.res<y.res) {
			res.lb=y.lb;
			res.rb=y.rb;
			res.res=y.res;
		}
		else if (x.res>y.res) {
			res.lb=x.lb;
			res.rb=x.rb;
			res.res=x.res;
		}
		else {
			res.lb=x.lb;
			res.rb=y.rb;
			res.res=x.res;
		}
		res.mlb=max(x.mlb,y.mlb);
		res.mrb=min(x.mrb,y.mrb);
		res.a0=min(y.mrb-x.mlb+1,min(x.a0,y.a0));
		return res;
	}
	int tag[2*N];
	void single (int p,int x) {
		tag[p]+=x;
		val[p].res+=x;
	}
	void pushdown (int p) {
		if (tag[p]) {
			single (ls[p],tag[p]);
			single (rs[p],tag[p]);
			tag[p]=0;
		}
	}
	void modify (int p,int tl,int tr,int ml,int mr,int x) {
		if (ml<=tl&&tr<=mr) single (p,x);
		else {
			pushdown (p);
			int mid=(tl+tr)>>1;
			if (ml<=mid) modify (ls[p],tl,mid,ml,mr,x);
			if (mr>mid) modify (rs[p],mid+1,tr,ml,mr,x);
			val[p]=merge (val[ls[p]],val[rs[p]]);
		}
	}
	void modify2 (int p,int tl,int tr,int k,int mlb,int mrb) {
		if (tl==tr) {
			val[p].mlb=mlb;
			val[p].mrb=mrb;
		}
		else {
			pushdown (p);
			int mid=(tl+tr)>>1;
			if (k<=mid) modify2 (ls[p],tl,mid,k,mlb,mrb);
			else modify2 (rs[p],mid+1,tr,k,mlb,mrb);
			val[p]=merge (val[ls[p]],val[rs[p]]);
		}
	}
	int build (int tl,int tr) {
		int p=++cnt;
		if (tl!=tr) {
			int mid=(tl+tr)>>1;
			ls[p]=build (tl,mid);
			rs[p]=build (mid+1,tr);
			val[p]=merge (val[ls[p]],val[rs[p]]);
		}
		else {
			val[p].lb=val[p].rb=tl;
		}
		return p;
	}
}
multiset<int> l2r[N],r2l[N];
int q,tot;
void update (int x) {
	int mlb=-inf,mrb=inf;
	if (r2l[x].size ()) mlb=*r2l[x].rbegin ();
	if (l2r[x].size ()) mrb=*l2r[x].begin ();
	sgt::modify2 (1,1,1000000,x,mlb,mrb);
}
int main () {
	freopen("stone.in","r",stdin);
	freopen("stone.out","w",stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	char op; int l,r;
	cin>>q;
	sgt::build (1,1000000);
	while (q--) {
		cin>>op>>l>>r;
		r--;
		if (op=='A') {
			sgt::modify (1,1,1000000,l,r,1);
			l2r[l].insert (r);
			r2l[r].insert (l);
			update (l);
			update (r);
			tot++;
		}
		else {
			sgt::modify (1,1,1000000,l,r,-1);
			l2r[l].erase (l2r[l].find (r));
			r2l[r].erase (r2l[r].find (l));
			update (l);
			update (r);
			tot--;
		}
		auto res=sgt::val[1];
		if (res.res==tot) {
			cout<<(*l2r[res.lb].begin ())-(*r2l[res.rb].rbegin ())+1<<"\n";
		}
		else cout<<res.a0<<"\n";
	}
	return 0;
}
